package com.atwei.mango.system.securityHandler;

import com.atwei.mango.system.apiModel.response.ApiResponse;
import com.atwei.mango.system.exception.ResponseEnum;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Classname UserNotLoginHandler
 * @Description 未登录控制类
 * @Date 2022/6/9 16:06
 * @Author liuwei
 */
@Component
public class UserNotLoginHandler implements AuthenticationEntryPoint {
    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
        ApiResponse.responseJson(response,ApiResponse.info(ResponseEnum.LOGIN_NOT,authException.getMessage()));
    }
}
